Git Pocket Guide by Richard E. Silverman

Git Pocket Guide by Richard E. Silverman

Author:Richard E. Silverman
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Software Development & Engineering / General
ISBN: 9781449325855
Publisher: O’Reilly Media
Published: 2013-06-24T16:00:00+00:00


Tip

In simple cases, you may get what you think of as the history of “this branch” with git log --first-parent, which just follows the first parent of merge commits rather than all of them. However, this isn’t guaranteed, and in more complex histories it won’t mean much. Since Git allows nonlinear history, a simple list of commits is often not very useful, and you need visualization tools to help you interpret it (see Visual Tools).

Resolving Merge Conflicts

Git doesn’t have built-in tools to interactively address merge conflicts directly; that’s what external merge tools are for, which we’ll consider shortly in Merge Tools. However, here are some tips for use in simple cases.

git log -p --merge shows all commits containing changes relevant to any unmerged files, on either branch, together with their diffs. This can help you identify the changes in the history that led to the conflicts.

If you want to discard all the changes from one side of the merge, use git checkout --{ours,theirs} file to update the working file with the copy from the current or other branch, followed by git add file to stage the change and mark the conflict as resolved.

Having done that, if you would like to apply some of the changes from the opposite side, use git checkout -p branch file. This starts an interactive loop that allows you to selectively apply or edit differing sections (see the “patch” item in the “Interactive Mode” section of git-add(1) for details).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.